﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbDimData : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbDimData(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbDimData obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbDimData()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbDimData(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public OdDbDimData() : this(TD_DbPINVOKE.new_OdDbDimData__SWIG_0(), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbDimData(OdDbDimension pDim, DimDataSetValueDelegate setDimFunc, uint bitFlags, IntPtr appData, DimDataSetCustomStringDelegate setCustomStringFunc) : this(TD_DbPINVOKE.new_OdDbDimData__SWIG_1(OdDbDimension.getCPtr(pDim), setDimFunc, bitFlags, appData, setCustomStringFunc), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbDimData(OdDbDimension pDim, DimDataSetValueDelegate setDimFunc, uint bitFlags, IntPtr appData) : this(TD_DbPINVOKE.new_OdDbDimData__SWIG_2(OdDbDimension.getCPtr(pDim), setDimFunc, bitFlags, appData), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbDimData(OdDbDimension pDim, DimDataSetValueDelegate setDimFunc, uint bitFlags) : this(TD_DbPINVOKE.new_OdDbDimData__SWIG_3(OdDbDimension.getCPtr(pDim), setDimFunc, bitFlags), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbDimData(OdDbDimension pDim, DimDataSetValueDelegate setDimFunc) : this(TD_DbPINVOKE.new_OdDbDimData__SWIG_4(OdDbDimension.getCPtr(pDim), setDimFunc), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbDimData(OdDbDimension pDim) : this(TD_DbPINVOKE.new_OdDbDimData__SWIG_5(OdDbDimension.getCPtr(pDim)), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbDimData(OdDbDimData arg0) : this(TD_DbPINVOKE.new_OdDbDimData__SWIG_6(OdDbDimData.getCPtr(arg0)), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbDimData Assign(OdDbDimData arg0)
		{
			OdDbDimData result = new OdDbDimData(TD_DbPINVOKE.OdDbDimData_Assign(this.swigCPtr, OdDbDimData.getCPtr(arg0)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbDimension dimension()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbDimData_dimension(this.swigCPtr);
			OdDbDimension result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbDimension)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbDimension)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbDimension)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDimension(OdDbDimension pDim)
		{
			TD_DbPINVOKE.OdDbDimData_setDimension(this.swigCPtr, OdDbDimension.getCPtr(pDim));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbObjectId ownerId()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr cPtr = TD_DbPINVOKE.OdDbDimData_ownerId(this.swigCPtr);
			OdDbObjectId result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbObjectId(cPtr, true));
				result = new OdDbObjectId(cPtr, false);
			}
			else
			{
				result = new OdDbObjectId(cPtr, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setOwnerId(OdDbObjectId objId)
		{
			TD_DbPINVOKE.OdDbDimData_setOwnerId(this.swigCPtr, OdDbObjectId.getCPtr(objId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public uint bitFlags()
		{
			uint result = TD_DbPINVOKE.OdDbDimData_bitFlags(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setBitFlags(uint flags)
		{
			TD_DbPINVOKE.OdDbDimData_setBitFlags(this.swigCPtr, flags);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isDimFocal()
		{
			bool result = TD_DbPINVOKE.OdDbDimData_isDimFocal(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDimFocal(bool focal)
		{
			TD_DbPINVOKE.OdDbDimData_setDimFocal(this.swigCPtr, focal);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isDimEditable()
		{
			bool result = TD_DbPINVOKE.OdDbDimData_isDimEditable(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDimEditable(bool editable)
		{
			TD_DbPINVOKE.OdDbDimData_setDimEditable(this.swigCPtr, editable);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isDimInvisible()
		{
			bool result = TD_DbPINVOKE.OdDbDimData_isDimInvisible(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDimInvisible(bool invisible)
		{
			TD_DbPINVOKE.OdDbDimData_setDimInvisible(this.swigCPtr, invisible);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isDimHideIfValueIsZero()
		{
			bool result = TD_DbPINVOKE.OdDbDimData_isDimHideIfValueIsZero(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDimHideIfValueIsZero(bool hide)
		{
			TD_DbPINVOKE.OdDbDimData_setDimHideIfValueIsZero(this.swigCPtr, hide);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public IntPtr appData()
		{
			IntPtr result = TD_DbPINVOKE.OdDbDimData_appData(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setAppData(IntPtr appData)
		{
			TD_DbPINVOKE.OdDbDimData_setAppData(this.swigCPtr, appData);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public IntPtr dimValueFunc()
		{
			IntPtr result = TD_DbPINVOKE.OdDbDimData_dimValueFunc(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDimValueFunc(DimDataSetValueDelegate funcPtr)
		{
			TD_DbPINVOKE.OdDbDimData_setDimValueFunc(this.swigCPtr, funcPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public IntPtr customStringFunc()
		{
			IntPtr result = TD_DbPINVOKE.OdDbDimData_customStringFunc(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setCustomStringFunc(DimDataSetCustomStringDelegate funcPtr)
		{
			TD_DbPINVOKE.OdDbDimData_setCustomStringFunc(this.swigCPtr, funcPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isDimResultantLength()
		{
			bool result = TD_DbPINVOKE.OdDbDimData_isDimResultantLength(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDimResultantLength(bool bValue)
		{
			TD_DbPINVOKE.OdDbDimData_setDimResultantLength(this.swigCPtr, bValue);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isDimDeltaLength()
		{
			bool result = TD_DbPINVOKE.OdDbDimData_isDimDeltaLength(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDimDeltaLength(bool bValue)
		{
			TD_DbPINVOKE.OdDbDimData_setDimDeltaLength(this.swigCPtr, bValue);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isDimResultantAngle()
		{
			bool result = TD_DbPINVOKE.OdDbDimData_isDimResultantAngle(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDimResultantAngle(bool bValue)
		{
			TD_DbPINVOKE.OdDbDimData_setDimResultantAngle(this.swigCPtr, bValue);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isDimDeltaAngle()
		{
			bool result = TD_DbPINVOKE.OdDbDimData_isDimDeltaAngle(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDimDeltaAngle(bool bValue)
		{
			TD_DbPINVOKE.OdDbDimData_setDimDeltaAngle(this.swigCPtr, bValue);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isDimRadius()
		{
			bool result = TD_DbPINVOKE.OdDbDimData_isDimRadius(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDimRadius(bool bValue)
		{
			TD_DbPINVOKE.OdDbDimData_setDimRadius(this.swigCPtr, bValue);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isCustomDimValue()
		{
			bool result = TD_DbPINVOKE.OdDbDimData_isCustomDimValue(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setCustomDimValue(bool custom)
		{
			TD_DbPINVOKE.OdDbDimData_setCustomDimValue(this.swigCPtr, custom);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isConstrained()
		{
			bool result = TD_DbPINVOKE.OdDbDimData_isConstrained(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setConstrain(bool bValue)
		{
			TD_DbPINVOKE.OdDbDimData_setConstrain(this.swigCPtr, bValue);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isCustomString()
		{
			bool result = TD_DbPINVOKE.OdDbDimData_isCustomString(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setCustomString(bool bValue)
		{
			TD_DbPINVOKE.OdDbDimData_setCustomString(this.swigCPtr, bValue);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;

		[Flags]
		public enum DimDataFlags
		{
			kDimEditable = 1,
			kDimInvisible = 2,
			kDimFocal = 4,
			kDimHideIfValueIsZero = 8,
			kDimEmptyData = 16,
			kDimResultantLength = 32,
			kDimDeltaLength = 64,
			kDimResultantAngle = 128,
			kDimDeltaAngle = 256,
			kDimRadius = 512,
			kDimCustomValue = 1024,
			kDimConstrained = 2048,
			kDimCustomString = 4096
		}
	}
}
